/*===============================================================================
*  Name:        ROTO DLL INTERFACE
*  Created:     2010-03-14
//=============================================================================*/
#pragma once


#include "ExtDescript.h"
#include "ExtTypes.h"

//API Interface
#include "../ICoreAPI.h"
#include "ExtDef.h"





#ifdef XDLL_IMPORTS
	#define XDLL __declspec(dllimport)
#else
	#define XDLL __declspec(dllexport)
#endif

 #ifdef __cplusplus
 extern "C" {
 #endif

/*===============================================================================
General plugin interface 
===============================================================================*/

class UndefExtension
{
protected:
	unsigned int m_obj;
	unsigned int m_ID;
	ICoreAPI * m_API;
public:
	UndefExtension(void){};
public:
	~UndefExtension(void){};
public:

	ICoreAPI* GetAPI()
	{
		return m_API;
	};

	void init(int id, ICoreAPI * api)
	{
		m_API = api;
		m_ID = id;
		m_obj = 0;
		startX();
	};

	int RegObj()
	{
		m_obj++;
		return m_obj;
	};

	int  GetID()
	{
		return m_ID;
	};

	int GetObjCount()
	{
		return m_obj;
	};

	roImage * GetImage(bool iscopy = false)
	{
		return GetAPI()->GetImage(GetID(), iscopy);
	};

	void SetImage(roImage * data, const wxString &description = "")
	{	
		GetAPI()->SetImage(GetID(), data, description);
	};

	void AddToMenu(
			   const wxString &menu,
			   const wxString &title,
			   const wxString &tooltip = ""
			   )
	{
		GetAPI()->_append_to_menu(GetID(), menu, title, tooltip);
	};

	virtual bool isok()
	{
		//func, that indicate , thats all OK!
		return true;	
	};
	virtual void startX(){};
	virtual void unset(){};

	virtual int GetType() = 0;
	virtual ExtDescript * GetDescription() = 0;
	virtual bool callback(int event_type, int argc, ...) = 0;

};

/*===============================================================================
| Plugin creator 
===============================================================================*/
XDLL int GetExtensionsNum();
XDLL UndefExtension * GetExtension(int index);

 #ifdef __cplusplus
 }
 #endif

typedef UndefExtension* (*NewExtension)(int index);
typedef int (*NumOfExt)();

